﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Web.Mvc;
using Project.Module;
using Project.Module.Common;
using Project.Module.DAO;
using Project.Module.DAO.BL;
using Project.Module.DAO.CMSBL;
using Project.Module.Model;
using Project.Module.Model.CMS;
using Project.Engine.Control;
using Project.Engine.Utilities;

namespace Project.Module.View.CMS
{
    public class CMSSearchSupplierView : BasePageRazor
    {
        public string keywordSupplier = String.Empty;
        public string keywordAddress = String.Empty;
        public string keywordDesc = String.Empty;
        public string choice = "0";
        public List<SupplierModel> listSupplier { get; set; }
        private ProductBL productBl = new ProductBL();
        private SupplierBL supplierBl = new SupplierBL();

        protected override void InitializePage()
        {
            base.InitializePage();

            if (Request["keywordSupplier"] != null || Request["keywordAddress"] != null || Request["keywordDesc"] != null)
            {
                keywordSupplier = Request["keywordSupplier"] != "  " ? SecurityUtil.RemoveSqlInjection(Request["keywordSupplier"].ToString()) : String.Empty;
                keywordAddress = Request["keywordAddress"] != "  " ? SecurityUtil.RemoveSqlInjection(Request["keywordAddress"].ToString()) : String.Empty;
                keywordDesc = Request["keywordDesc"] != "  " ? SecurityUtil.RemoveSqlInjection(Request["keywordDesc"].ToString()) : String.Empty;

                if (keywordSupplier == String.Empty && keywordAddress == String.Empty && keywordDesc == String.Empty)
                {
                    listSupplier = null;
                }
                else
                {
                    listSupplier = supplierBl.Search(keywordSupplier, keywordAddress, keywordDesc);
                }
            }
        }
    }
}
